// import { resolve } from 'core-js/fn/promise';
import {
  createRouter,
  createWebHashHistory,
  createWebHistory
} from 'vue-router'

const routes = [{
    path: '/',
    name: 'home',
    meta: {
      title: '范文亮的简历'
    },
    component: () => import('../views/Home.vue')
  },
  {
    path: '/test',
    name: 'test',
     meta: {
      title:'测试'
    },
    component: () => import('../views/Test.vue')
  },
  {
    path: '/codeGarden',
    name: 'CodeGarden',
    meta: {
      title:'秘密花园'
    },
    component: () => import('../views/CodeGarden.vue')
  },
  {
    path: '/SecondViews/expandingCards',
    name: 'ExpandingCards',
    meta: {
      title:'花骨朵'
    },
    component: () => import('../views/SecondViews/expandingCards.vue')
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})
router.beforeEach((to) => {
  document.title = to.meta.title;
  let timer;
  document.addEventListener('visibilitychange', function () {
    // 用户息屏、或者切到后台运行 （离开页面） 
    if (document.visibilityState === 'hidden') {
      clearTimeout(timer)
      const arr = [
        'ヾ(￣▽￣)Bye~Bye~ 录用他',
        '=͟͟͞͞(꒪⌓꒪*)你咋走了 录用他',
        '(；′⌒`)记得回来 录用他',
        '‎(,,•́ . •̀,,)记得回来 录用他',
        '‎(●︎˘͈ ᵕ˘͈)在等你哦 录用他',
        '(づ ●─● )づ你别走呀 录用他',
        '(ง •̀_•́)ง我在这里 录用他',
        '<(｀^´)快点回来 录用他',
      ]
      document.title = arr[Math.ceil(Math.random() * 7)]
    }
    // 用户打开或回到页面 
    if (document.visibilityState === 'visible') {
      clearTimeout(timer)
      const arr = [
        '⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄你回来辣',
        '(✿◡‿◡)你回来辣',
        '✧ʕ̢̣̣̣̣̩̩̩̩·͡˔·ོɁ̡̣̣̣̣̩̩̩̩✧你回来辣',
        '‎₍˄·͈༝·͈˄₎◞你回来辣',
        '(๑>؂<๑)你回来辣',
        '(づ ●─● )づ你回来辣',
        '(ง •̀_•́)ง你回来辣',
        'ᴗ͈ˬᴗ͈ෆ你回来辣',
        '꒰ᐢ⸝⸝•༝•⸝⸝ᐢ꒱你回来辣',
      ]
      document.title = arr[Math.ceil(Math.random() * 8)]
      timer = setTimeout(() => {
        document.title = to.meta.title
      }, 5000)
    }
  })
});


export default router